package com.nisco.dms.entity;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.apache.commons.lang3.builder.ToStringBuilder;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import com.google.common.collect.Lists;

@Entity
@Table(name = "Ds_Role")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE, region = "org.springside.examples.quickstart.entity")
public class Role extends CoreEntity {

	@Column(nullable = false, length = 100)
	private String strName;
	
	@Column(length = 20)
	private String strSn;
	
	@OneToMany(cascade=CascadeType.ALL)
	@JoinColumn(name="roleId")
	private List<RolePermission> permissionList = Lists.newArrayList();
	@OneToMany(mappedBy = "role", cascade = CascadeType.ALL)
	private List<UserRole> userRoles = new ArrayList<UserRole>(0);

	
	public String getStrName()
	{
		return strName;
	}

	public void setStrName(String strName)
	{
		this.strName = strName;
	}

	public String getStrSn()
	{
		return strSn;
	}

	public void setStrSn(String strSn)
	{
		this.strSn = strSn;
	}

	/**
	 * 返回 userRoles 的值
	 * 
	 * @return userRoles
	 */
	public List<UserRole> getUserRoles() {
		return userRoles;
	}

	/**
	 * 设置 userRoles 的值
	 * 
	 * @param userRoles
	 */
	public void setUserRoles(List<UserRole> userRoles) {
		this.userRoles = userRoles;
	}

	
	public List<RolePermission> getPermissionList()
	{
		return permissionList;
	}

	public void setPermissionList(List<RolePermission> permissionList)
	{
		this.permissionList = permissionList;
	}

	
	
	/**
	 * reflectionToString将对象输出为string类型。
	 */
	@Override
	public String toString() {
		return ToStringBuilder.reflectionToString(this);
	}

/*	public List<String> getPermissionList()
	{
		return permissionList;
	}

	public void setPermissionList(List<String> permissionList)
	{
		this.permissionList = permissionList;
	}*/

}
